package org.example.utils;


import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class JDBCUtils {


    public static String URL;

    public static String USERNAME;

    public static String PASSWORD;

    static {
        Properties prop = new Properties();
        InputStream input = null;
        try {
            input = JDBCUtils.class.getClassLoader().getResourceAsStream("application.properties");
            prop.load(input);
        } catch (Exception e) {
            throw new RuntimeException();
        }
        URL = prop.getProperty("jdbcplus.mysql.url");
        USERNAME = prop.getProperty("jdbcplus.mysql.username");
        PASSWORD = prop.getProperty("jdbcplus.mysql.password");
    }
    public static Connection getConnection(){
        Connection conn = null;

        try {
            conn = DriverManager.getConnection(URL,USERNAME,PASSWORD);

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return conn;
    }


}
